﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BusinessLayer;

namespace DeAn_LapTrinhCSDL
{
    public partial class frmReport : Form
    {
        public string reportObject;
        public DataTable data;
        public frmReport()
        {
            InitializeComponent();
        }

        private void ReportForm_Load(object sender, EventArgs e)
        {
            CreateReport();
        }

        public void CreateReport()
        {
            switch (reportObject)
            {
                case "NhaCC":
                    {
                        NhaCC ncc = new NhaCC();
                        ncc.connect.ConnectionString = Program.strConnect;
                        Report.rpNhaCC rpt = new DeAn_LapTrinhCSDL.Report.rpNhaCC();
                        rpt.DataSource = ncc.GetData();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }
                case "VatTu":
                    {
                        VatTu vt = new VatTu();
                        vt.connect.ConnectionString = Program.strConnect;
                        Report.rpVatTu rpt = new DeAn_LapTrinhCSDL.Report.rpVatTu();
                        rpt.DataSource = vt.GetData();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }
                case "DonDH":
                    {
                        DonDH ddh = new DonDH();
                        ddh.connect.ConnectionString = Program.strConnect;
                        Report.rpDonDH rpt = new DeAn_LapTrinhCSDL.Report.rpDonDH();
                        rpt.DataSource = ddh.GetData();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }
                case "PNhap":
                    {
                        PNhap pn = new PNhap();
                        pn.connect.ConnectionString = Program.strConnect;
                        Report.rpPNhap rpt = new DeAn_LapTrinhCSDL.Report.rpPNhap();
                        rpt.DataSource = pn.GetData();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }
                case "PXuat":
                    {
                        PXuat px = new PXuat();
                        px.connect.ConnectionString = Program.strConnect;
                        Report.rpPXuat rpt = new DeAn_LapTrinhCSDL.Report.rpPXuat();
                        rpt.DataSource = px.GetData();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }
                case "ThongKeTinhHinhDatNhap":
                    {
                        DonDH dh = new DonDH();
                        dh.connect.ConnectionString = Program.strConnect;
                        Report.rpThongKeTinhHinhDatNhap rpt = new DeAn_LapTrinhCSDL.Report.rpThongKeTinhHinhDatNhap();
                        rpt.DataSource = dh.GetData();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }
                case "TongSLNhap":
                    {
                        if (data != null)
                        {
                            Report.rpThongKeTongSLNhap rpt = new DeAn_LapTrinhCSDL.Report.rpThongKeTongSLNhap();
                            rpt.DataSource = data;
                            printControl1.PrintingSystem = rpt.PrintingSystem;
                            rpt.CreateDocument();
                        }
                        break;
                    }
                case "TongSLXuat":
                    {
                        if (data != null)
                        {
                            Report.rpThongKeTongSLXuat rpt = new DeAn_LapTrinhCSDL.Report.rpThongKeTongSLXuat();
                            rpt.DataSource = data;
                            printControl1.PrintingSystem = rpt.PrintingSystem;
                            rpt.CreateDocument();
                        }
                        break;
                    }
                case "DanhSachDonDHChuaTungNhapHang":
                    {
                        DonDH dh = new DonDH();
                        dh.connect.ConnectionString = Program.strConnect;
                        Report.rpDanhSachDonDHChuaNhapHang rpt = new DeAn_LapTrinhCSDL.Report.rpDanhSachDonDHChuaNhapHang();
                        rpt.DataSource = dh.DanhSachDonDHChuaTungNhapHang();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }

                case "DanhSachVatTuChuaTungDatHang":
                    {
                        VatTu vt = new VatTu();
                        vt.connect.ConnectionString = Program.strConnect;
                        Report.rpVatTu rpt = new DeAn_LapTrinhCSDL.Report.rpVatTu();
                        rpt.headerText = "DANH SÁCH VẬT TƯ CHƯA TỪNG ĐẶT HÀNG";
                        rpt.DataSource = vt.DanhSachVatTuChuaTungDatHang();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }
                case "NhaCungCapCoNhieuDonDHNhat":
                    {
                        NhaCC ncc = new NhaCC();
                        ncc.connect.ConnectionString = Program.strConnect;
                        Report.rpNhaCC rpt = new DeAn_LapTrinhCSDL.Report.rpNhaCC();
                        rpt.headerText = "NHÀ CUNG CẤP CÓ NHIỀU ĐƠN ĐẶT HÀNG NHẤT";
                        rpt.DataSource = ncc.NhaCungCapCoNhieuDonDHNhat();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }
                case "VatTuCoSoLuongXuatNhieuNhat":
                    {
                        VatTu vt = new VatTu();
                        vt.connect.ConnectionString = Program.strConnect;
                        Report.rpVatTu rpt = new DeAn_LapTrinhCSDL.Report.rpVatTu();
                        rpt.headerText = "VẬT TƯ CÓ SỐ LƯỢNG XUẤT NHIỀU NHẤT";
                        rpt.DataSource = vt.VatTuCoSoLuongXuatNhieuNhat();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }
                case "TinhHinhNhapXuatVatTu":
                    {
                        VatTu vt = new VatTu();
                        vt.connect.ConnectionString = Program.strConnect;
                        Report.rpTinhHinhXuatNhapVatTu rpt = new DeAn_LapTrinhCSDL.Report.rpTinhHinhXuatNhapVatTu();
                        rpt.DataSource = vt.TinhHinhNhapXuatVatTu();
                        printControl1.PrintingSystem = rpt.PrintingSystem;
                        rpt.CreateDocument();
                        break;
                    }
                case "TinhHinhTonKho":
                    {
                        if (data != null)
                        {
                            Report.rpTinhHinhTonKho rpt = new DeAn_LapTrinhCSDL.Report.rpTinhHinhTonKho();
                            rpt.DataSource = data;
                            printControl1.PrintingSystem = rpt.PrintingSystem;
                            rpt.CreateDocument();
                        }
                        break;
                    }

            }
        }
    }
}